package com.ssy.lingxi.platform.manage.controller.content;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.content.ContentColumn;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.request.common.CommonStatusRequest;
import com.ssy.lingxi.platform.manage.model.request.content.ContentColumnPageRequest;
import com.ssy.lingxi.platform.manage.model.request.content.ContentColumnRequest;
import com.ssy.lingxi.platform.manage.model.response.HotColumnResponse;
import com.ssy.lingxi.platform.manage.service.content.IContentColumnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu 内容管理 - 栏目管理
 * @author fhj
 * @version 2.0.0
 * @date 2020/9/18
 */
@Api(tags = "内容管理 - 栏目管理")
@RestController
@RequestMapping("/manage/contentColumn")
public class ContentColumnController extends BaseController {

    @Resource
    private IContentColumnService contentColumnService;

    @ApiOperation(value = "列表")
    @GetMapping("/page")
    public Wrapper<PageData<ContentColumn>> page(ContentColumnPageRequest request) {
        return contentColumnService.page(request);
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/get")
    public Wrapper<ContentColumn> get(@Validated CommonIdRequest request) {
        return contentColumnService.get(request);
    }

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Validated({ContentColumnRequest.Add.class}) ContentColumnRequest request) {
        return contentColumnService.add(request, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({ContentColumnRequest.Update.class}) ContentColumnRequest request) {
        return contentColumnService.update(request, getSysUser());
    }

    @ApiOperation(value = "停用/启用")
    @PostMapping(value = "/updateStatus")
    public Wrapper<Void> updateStatus(@RequestBody @Validated ({CommonStatusRequest.Enable.class}) CommonStatusRequest request) {
        return contentColumnService.updateStatus(request, getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Validated CommonIdRequest request) {
        return contentColumnService.delete(request, getSysUser());
    }

    @ApiOperation(value = "所有")
    @GetMapping(value = "/all")
    public Wrapper<List<ContentColumn>> all(Integer type) {
        return contentColumnService.all(type);
    }

    @ApiOperation(value = "所有（市场行情）")
    @GetMapping(value = "/allByMarket")
    public Wrapper<List<ContentColumn>> allByMarket() {
        return contentColumnService.allByMarket();
    }

    @ApiOperation(value = "热门栏目")
    @GetMapping(value = "/hot")
    public Wrapper<List<HotColumnResponse>> hot() {
        return contentColumnService.hot();
    }
}
